<template>
  <el-dialog title="角色分配" :visible="showAss" @close="open">
    <el-checkbox-group v-model="checkList">
      <el-checkbox v-for="item in list " :key="item.id" style="margin-top: 20px" :label="item.id" border>
        {{ item.name }}
      </el-checkbox>
    </el-checkbox-group>
    <el-row style="margin-top: 20px">
      <el-button type="primary" @click="hShan">确认</el-button>
      <el-button @click="open">取消</el-button>
    </el-row>
  </el-dialog>
</template>

<script>
import { getAssignRoles, getEmployeeDetail, getEnabled } from '@/api/employee'
export default {
  props: {
    showAss: {
      type: Boolean
    },
    showId: {
      type: [Number, String],
      required: true
    }
  },
  data() {
    return {
      list: '',
      checkList: []
    }
  },
  created() {
    this.updata()
  },
  methods: {
    async hShan() {
      await getAssignRoles({ roleIds: this.checkList, id: this.showId })
      this.open()
    },
    open() {
      this.$emit('update:showAss', false)
    },
    async updata() {
      const res = await getEnabled()
      console.log(res)
      this.list = res.data
    },
    async upEmployeeDetail() {
      const res = await getEmployeeDetail(this.showId)
      this.checkList = res.data.roleIds
    }
  }
}
</script>

<style>

</style>
